package com.net.xpay.core.dao;

import com.net.xpay.core.domain.PayTrans;
import com.net.xpay.core.enums.PayTransStatus;
import com.net.xpay.core.model.PayTransSearchModel;
import com.net.xpay.core.model.QueryRepeatModel;
import com.net.common.dao.Page;
import com.net.common.dao.VersionedMapper;
import com.net.common.annotation.DataShard;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@DataShard("")
@Repository
public interface PayTransMapper extends VersionedMapper<Long, PayTrans> {
    int batchSave(@Param("payTrans") List<PayTrans> payTrans);

    int updateStatusByPayTransBatchId(@Param("userId") Long userId, @Param("payTransBatchId") Long payTransBatchId, @Param("status") PayTransStatus status, @Param("free") Boolean free, @Param("endTime") LocalDateTime endTime);

    List<PayTrans> findByUserIdAndOutBizNoIn(@Param("userId") Long userId, @Param("outBizNos") List<String> outBizNos);

    int updateStatus(@Param("userId") Long userId, @Param("id") Long id, @Param("status") PayTransStatus status);

    List<PayTrans> search(@Param("searchModel") PayTransSearchModel searchModel, @Param("page") Page page);

    long searchCount(@Param("searchModel") PayTransSearchModel searchModel);

    int batchUpdate(@Param("payTrans") List<PayTrans> payTrans);

    List<PayTrans> list(@Param("searchModel") PayTransSearchModel searchModel);

    long statSingleVeryCount(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    List<Long> listSingleVeryMerchantIds(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    List<QueryRepeatModel> queryMayRepeatPayTransWithType1(@Param("userId") Long userId, @Param("minCreateTime") LocalDateTime minCreateTime, @Param("maxCreateTime") LocalDateTime maxCreateTime);

    List<QueryRepeatModel> queryMayRepeatPayTransWithType2(@Param("userId") Long userId, @Param("minCreateTime") LocalDateTime minCreateTime, @Param("maxCreateTime") LocalDateTime maxCreateTime);

    long statFailSingleVeryCount(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    long statUserSingleVeryCount(@Param("userId") Long userId, @Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    long statUserFailSingleVeryCount(@Param("userId") Long userId, @Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    long statPayTransPayeeAlipayAccount(@Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);

    long statUserLargeCount(@Param("userId") Long userId, @Param("minEndTime") LocalDateTime minEndTime, @Param("maxEndTime") LocalDateTime maxEndTime);
}
